{% extends 'base.html' %}

{% block title %}更改密码 - EasyTesting{% endblock %}

{% block header %}更改密码{% endblock %}

{% block content %}

    <div class="card">
        <div class="card-body">
            <form method="post">
                {% csrf_token %}

                {% if form.errors %}
                    <div class="alert alert-danger">
                        <i class="bi bi-exclamation-triangle-fill me-2"></i>
                        请修正以下错误:
                        <ul class="mb-0 mt-2">
                            {% for field in form %}
                                {% for error in field.errors %}
                                    <li>{{ field.label }}: {{ error }}</li>
                                {% endfor %}
                            {% endfor %}
                            {% for error in form.non_field_errors %}
                                <li>{{ error }}</li>
                            {% endfor %}
                        </ul>
                    </div>
                {% endif %}

                <div class="mb-4">
                    <label for="id_old_password" class="form-label fw-medium">当前密码</label>
                    <input type="password" name="old_password" id="id_old_password" class="form-control" required>
                    <div class="form-text">输入您当前的密码，以验证您的身份。</div>
                </div>

                <div class="mb-4">
                    <label for="id_new_password1" class="form-label fw-medium">新密码</label>
                    <input type="password" name="new_password1" id="id_new_password1" class="form-control" required>
                    <div class="form-text">
                        <ul>
                            <li>密码不能与个人信息太相似。</li>
                            <li>密码必须至少包含 8 个字符。</li>
                            <li>密码不能是常用密码。</li>
                            <li>密码不能全为数字。</li>
                        </ul>
                    </div>
                </div>

                <div class="mb-4">
                    <label for="id_new_password2" class="form-label fw-medium">确认新密码</label>
                    <input type="password" name="new_password2" id="id_new_password2" class="form-control" required>
                    <div class="form-text">请输入与上面相同的密码，以进行验证。</div>
                </div>

                <div class="d-flex justify-content-between mt-4">
                    <a href="{% url 'profile' %}" class="btn btn-outline-secondary">
                        <i class="bi bi-arrow-left"></i> 返回
                    </a>
                    <button type="submit" class="btn btn-primary px-4">
                        <i class="bi bi-check-lg"></i> 更改密码
                    </button>
                </div>
            </form>
        </div>
    </div>
{% endblock %}
